# 测试问候语识别功能
from question_classifier import QuestionClassifier
from answer_generator import AnswerGenerator

def test_greeting_recognition():
    print("=== 测试问候语识别功能 ===")
    
    # 测试问题分类
    qc = QuestionClassifier()
    
    test_questions = [
        "你好",
        "Hello",
        "Hi",
        "早上好",
        "你好吗？",
        "Good morning",
        "什么是所有权？",  # 非问候语
        "如何使用Vec？"   # 非问候语
    ]
    
    print("\n1. 测试问题分类:")
    for question in test_questions:
        try:
            # 使用规则分类测试
            result = qc._rule_based_classify(question)
            print(f"问题: '{question}' -> 分类: {result['label']} (置信度: {result['confidence']})")
        except Exception as e:
            print(f"问题: '{question}' -> 错误: {e}")
    
    print("\n2. 测试问候语回复生成:")
    ag = AnswerGenerator()
    
    greeting_questions = ["你好", "Hello", "Hi"]
    for question in greeting_questions:
        try:
            response = ag._generate_greeting_response(question)
            print(f"\n问题: '{question}'")
            print(f"回复长度: {len(response)}")
            print(f"回复预览: {response[:100]}...")
        except Exception as e:
            print(f"问题: '{question}' -> 错误: {e}")
    
    print("\n=== 测试完成 ===")

if __name__ == "__main__":
    test_greeting_recognition()
